<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>开始使用layui</title>
	<script type="text/javascript" src="../js/jquery-2.2.3.min.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>

<!-- 你的HTML代码 -->

<script src="../layui/layui.js"></script>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">货运单编号</label>
        <div class="layui-input-block">
            <input type="text" name="goodsBillCode" required  lay-verify="required" placeholder="货运单编号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script>
    //Demo
	
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
			$.ajax({
				url:"http://localhost:8080/addReceipt",
				type:"post",
				data:{
					"goodsBillCode":data.field.goodsBillCode
				},
				success:function(data){
					if(data.code=="0"){
						layer.msg(data.msg,{
							icon: 1,
						     time: 3000 
						})
						setTimeout(function() {
							parent.location.reload();
					          // location.reload();
					        }, 2000);
						//location.reload();
					}else{
						layer.msg(data.msg,{
							icon: 1,
						     time: 3000 
						})
					}
				}
			})
			 return false;
        });
    });
</script>
</body>
</html>